<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML>
	<HEAD>
		<META CONTENT="text/html; charset=UTF-8" HTTP-EQUIV="Content-Type">
		<TITLE>PI.JS > pi.util</TITLE>
		<LINK HREF="../../../inc/template.css" REL="stylesheet">
		<LINK HREF="../../../inc/template.css" REL="stylesheet">
		<SCRIPT SRC="../../../source/pi.1.1.1.js" TYPE="text/javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/template.js" TYPE="text/javascript"></SCRIPT>
		<LINK HREF="../../../inc/sh/SyntaxHighlighter.css" TYPE="text/css" REL="stylesheet">
		<SCRIPT SRC="../../../inc/sh/shCore.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushJScript.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushCss.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushXml.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushPhp.js" LANGUAGE="javascript"></SCRIPT>
		<SCRIPT SRC="../../../inc/sh/shBrushPython.js" LANGUAGE="javascript"></SCRIPT>
	</HEAD>
	<BODY>
		<A HREF="/" ID="header" CLASS="Header">
			<EM></EM>
		</A>
		<DIV CLASS="Index">
			<DIV ID="indexContainer" CLASS="ListContainer">
				<A HREF="../../../index.html" CLASS="Button "><EM>About Pi</EM></A>
				<A HREF="../../../pages/Downloads" CLASS="Button "><EM>Downloads</EM></A>
				<A HREF="../../../documentation/index.html" CLASS="Button SelectedButton"><EM>Documentation</EM></A>
				<DIV CLASS="SubNavigation">
					<DIV>
						<H2 CLASS="Title">Essential Documents</H2>
						<UL>
							<LI>
								<A STYLE="" HREF="../../../documentation/essential/Getting Started to pi.js/">Getting Started to pi.js</A>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/essential/Object Oriented Programming with pi.js/">Object Oriented Programming with pi.js</A>
							</LI>
						</UL>
					</DIV><DIV>
						<H2 CLASS="Title">Reference</H2>
						<UL>
							<LI>
								<A STYLE="" HREF="../../../documentation/env/pi.env/">pi.env</A>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/get/pi.get/">pi.get</A>
							</LI><LI>
								<A STYLE="font-weight:bold" HREF="../../../documentation/util/pi.util/">pi.util</A>
								<UL>
									<LI>
										<A HREF="../../../documentation/util/pi.util.Array/">pi.util.Array</A>
									</LI><LI>
										<A HREF="../../../documentation/util/pi.util.Element/">pi.util.Element</A>
									</LI><LI>
										<A HREF="../../../documentation/util/pi.util.Hash/">pi.util.Hash</A>
									</LI><LI>
										<A HREF="../../../documentation/util/pi.util.Number/">pi.util.Number</A>
									</LI><LI>
										<A HREF="../../../documentation/util/pi.util.String/">pi.util.String</A>
									</LI>
								</UL>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/base/pi.base/">pi.base</A>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/element/pi.element/">pi.element</A>
							</LI><LI>
								<A STYLE="" HREF="../../../documentation/xhr/pi.xhr/">pi.xhr</A>
							</LI><LI>
								<SPAN STYLE="font-weight:bold">Native Objects</SPAN>
								<UL>
									<LI>
										<A HREF="../../../documentation/Native Objects/Array/">Array</A>
									</LI><LI>
										<A HREF="../../../documentation/Native Objects/Function/">Function</A>
									</LI><LI>
										<A HREF="../../../documentation/Native Objects/Number/">Number</A>
									</LI><LI>
										<A HREF="../../../documentation/Native Objects/String/">String</A>
									</LI>
								</UL>
							</LI><LI>
								<SPAN STYLE="font-weight:bold">Plugins</SPAN>
								<UL>
									<LI>
										<A HREF="../../../documentation/plugin/pi.comet/">pi.comet</A>
									</LI><LI>
										<SPAN>pi.cache</SPAN>
									</LI><LI>
										<SPAN>pi.layer</SPAN>
									</LI><LI>
										<A HREF="../../../documentation/plugin/pi.storage/">pi.storage</A>
									</LI><LI>
										<SPAN>pi.win</SPAN>
									</LI>
								</UL>
							</LI>
						</UL>
					</DIV>
				</DIV>
				<A HREF="../../../pages/Plugins" CLASS="Button "><EM>Plugins</EM></A>
				<A HREF="http://groups.google.com/group/pi-js" CLASS="Button"><EM>Developer Forum</EM></A>
				<A HREF="http://code.google.com/p/pi-js/issues/list" CLASS="Button"><EM>Issues</EM></A>
			</DIV>
		</DIV>
		<!-- <h3 class="ContentNav" id="contentTitle">
			<div>
				<a class="Sel">index.html</a>
			</div>
		</h3>-->
		<DIV ID="documentationContent" CLASS="Content">
			<DIV CLASS="Pad">
				<H1 CLASS="Name">pi.util<EM CLASS="DocumentationTitleVersion">2009-01-06 09:23:27</EM></H1>
				<DIV>
				<H2 CLASS="Title">Summary</H2>
				pi.util is an object that contains some essential javascript tools.
				</DIV>
				<DIV CLASS="PageListContainer">
					<DIV CLASS="Page">
						<H2 CLASS="Title">Methods</H2>
						<DIV CLASS="PageItem">
							<A HREF="Methods/Curry/" CLASS="PageItemTitle">Curry</A>
							<CODE>pi.util.Curry(<EM>function</EM>,<EM>scope</EM>,<EM>arguments ...</EM>)</CODE>
							<DIV CLASS="PageItemSummary">Returns a generic curried version of specified function.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/Extend/" CLASS="PageItemTitle">Extend</A>
							<CODE>var <EM>className</EM> = pi.util.Extend(
	<EM>superClass</EM>,
	{
		"$Init":<EM>Constructor</EM>,
		<EM>property name</EM>:<EM>value</EM>,
		<EM>private member</EM>:<EM>value</EM>
	},
	<EM>boolean skipClonning (optional)</EM>
)
</CODE>
							<DIV CLASS="PageItemSummary">Provides creating javascript classes by using pi.base.With this function, you can extend a class with other classes. If not another class will be extended, pi.base should be send as the first parameter.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/IsArray/" CLASS="PageItemTitle">IsArray</A>
							<CODE>pi.util.IsArray(<EM>value</EM>);</CODE>
							<DIV CLASS="PageItemSummary">Finds whether a variable is an array</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/IsHash/" CLASS="PageItemTitle">IsHash</A>
							<CODE>pi.util.IsHash(<EM>value</EM>);</CODE>
							<DIV CLASS="PageItemSummary">Finds whether a variable is a hash.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/Init/" CLASS="PageItemTitle">Init</A>
							<CODE>pi.util.Init.push(<EM>function</EM>);</CODE>
							<DIV CLASS="PageItemSummary">An array containing functions that runs when DOM document is loaded.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/Import/" CLASS="PageItemTitle">Import</A>
							<CODE>pi.util.Import(<EM>file url</EM>,<EM>fileType (optional)</EM>);</CODE>
							<DIV CLASS="PageItemSummary">Includes a JS or CSS file to the page with a synchronous request.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/AddEvent/" CLASS="PageItemTitle">AddEvent</A>
							<CODE>pi.util.AddEvent(<EM>target</EM>,<EM>type</EM>,<EM>listener</EM>,<EM>useCapture</EM>);</CODE>
							<DIV CLASS="PageItemSummary">Allows the registration of event listeners on the event target.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/RemoveEvent/" CLASS="PageItemTitle">RemoveEvent</A>
							<CODE>pi.util.RemoveEvent(<EM>target</EM>,<EM>type</EM>,<EM>listener</EM>,<EM>useCapture</EM>);</CODE>
							<DIV CLASS="PageItemSummary">Allows the removal of event listeners on the event target.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/Include/" CLASS="PageItemTitle">Include</A>
							<CODE>pi.util.Include(<EM>url</EM>,<EM>callback</EM>);</CODE>
							<DIV CLASS="PageItemSummary">A Function that loads and executes javascript files using an HTTP GET request and allows cross domain JSON transfers.</DIV>
						</DIV><DIV CLASS="PageItem">
							<A HREF="Methods/GetViewport/" CLASS="PageItemTitle">GetViewport</A>
							<CODE>pi.util.GetViewport();</CODE>
							<DIV CLASS="PageItemSummary">Returns size of available space on the screen.</DIV>
						</DIV>
					</DIV>
				</DIV>
				<DIV CLASS="Block">
					<H1>Examples</H1>
					<DIV CLASS="Example">
						<H1>Example #1: Get mouse coordinates of mouse pointer when user click anywhere.</H1>
							<DIV CLASS="View">
								<LABEL>X Coordinate:</LABEL><INPUT TYPE="text" ID="x">
<LABEL>Y Coordinate:</LABEL><INPUT TYPE="text" ID="y">
<BUTTON ID="removeButton">Remove Event</BUTTON><SCRIPT SRC="examples/findCoordinates.js" TYPE="text/javascript"></SCRIPT>
							</DIV>
							<H2>Source files of the above example:</H2>
							<DIV>
								<H3>examples/findCoordinates.html</H3>
								<PRE NAME="code" CLASS="html">&lt;label>X Coordinate:&lt;/label>&lt;input id='x' type='text' />
&lt;label>Y Coordinate:&lt;/label>&lt;input id='y' type='text' />

&lt;button id='removeButton'>Remove Event&lt;/button></PRE>
							</DIV><DIV>
								<H3>examples/findCoordinates.js</H3>
								<PRE NAME="code" CLASS="js">var getCoordinates = function(_event){
	pi.get('x').value = _event.clientX;
	pi.get('y').value = _event.clientY;
};

var removeEvent = function(){
	pi.util.RemoveEvent(document.body,'click',getCoordinates);
};

/*
	Set events when dom content is ready.
*/

pi.util.AddEvent(document.body,'click',getCoordinates);
pi.util.AddEvent( pi.get('removeButton'), 'click', removeEvent )
</PRE>
							</DIV>
					</DIV>
				</DIV>
			</DIV>
		</DIV>
		<DIV CLASS="Clean"></DIV>
	</BODY> 
</HTML>